#[cfg(test)]
mod tests {
    /// 测试异步编程基础
    #[tokio::test]
    async fn test_async() {
        async fn async_add(a: i32, b: i32) -> i32 {
            a + b
        }
        assert_eq!(async_add(2, 3).await, 5);
    }

    /// 测试内部可变性模式
    #[test]
    fn test_interior_mutability() {
        use std::cell::RefCell;
        let counter = RefCell::new(0);
        *counter.borrow_mut() += 1;
        assert_eq!(*counter.borrow(), 1);
    }

    /// 测试迭代器适配器
    #[test]
    fn test_iterator() {
        let v = vec![1, 2, 3];
        let sum: u32 = v.iter()
            .map(|x| x * 2)
            .filter(|x| *x > 3)
            .sum();
        assert_eq!(sum, 10);
    }
}